package com.wa.authory;

import cn.hutool.core.util.StrUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 *  后端用户认证
 */
@Component
public class BackendLoginAuthor {

    /**
     * logger
     */
    private Logger logger = LoggerFactory.getLogger(BackendLoginAuthor.class);

//    @Resource
//    com.allchips.websocket.core.service.BaseService baseService;

    /**
     * 校验后端用户登陆
     *
     * @param token
     * @return
     */
    public boolean authorize(String token) {
        if (StrUtil.isNotEmpty(token)) {
            try {
//                BackendUserPojo backendUserInfo = baseService.getBackendUserInfoByToken(token);
//                if (null == backendUserInfo || null == backendUserInfo.getUser()) {
//                    return false;
//                }
//                Integer userId = backendUserInfo.getUser().getUserId();
//                if (userId < 0) {
//                    return false;
//                }
                return true;
            } catch (Exception e) {
                logger.error("校验后端用户登陆异常", e);
            }
        }
        return false;
    }

}
